package edu.uwm.universitydb.dao.professor;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import edu.uwm.universitydb.model.Professor;

public class GetProjectManagerCommand extends SearchProfessorCommandBase<Professor>
{
    /** sql portion representing where clause for name */
    private static final String SQL_QUERY =
        ",university.manage where university.manage.pno = ? and p.prof_ssn=university.manage.prof_ssn and "
            + "p.prof_ssn = university.works.prof_ssn and university.works.dno = d.dno";

    /** attribute holding the ssn */
    private final Integer mPid;

    /**
     * 
     * @param pid
     */
    public GetProjectManagerCommand(final int id)
    {
        mPid = id;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DataFetchCommand#processResult(java.sql.ResultSet)
     */
    @Override
    public Professor processResult(final ResultSet result) throws SQLException
    {
        if (result.next())
        {
            return getProfessor(result);
        }
        return null;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DBCommand#getSQL()
     */
    @Override
    public String getSQL()
    {
        return SELECT_SQL + SQL_QUERY;
    }

    /*
     * (non-javadoc)
     * @see edu.uwm.universitydb.framework.db.command.DBCommand#setParameters(java.sql.PreparedStatement)
     */
    @Override
    public void setParameters(final PreparedStatement pStmt) throws SQLException
    {
        pStmt.setInt(1, mPid);
    }
}
/*
 * ============================================================================
 * Change History
 * ----------------------------------------------------------------------------
 * Apr 19, 2014   Shyam Nair
 * File created
 * ----------------------------------------------------------------------------
 * Apr 21, 2014   Shyam Nair
 * Added Logic For Department
 * ----------------------------------------------------------------------------
 */